import {createApp} from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import LoginApp from './LoginApp.vue'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import {createRouter, createWebHashHistory} from 'vue-router'
import VueAxios from "vue-axios"
import axios from 'axios'
import qs from "qs";
import IndexPage from "@/components/IndexPage";
import QueryForm from "@/components/QueryForm";
import HighchartsVue from 'highcharts-vue'

import GoodsManagePage from "@/components/GoodsManagePage.vue";
import UserManagePage from "@/components/UserManagePage.vue";

const routes = [
    {
        path: "/",
        redirect: "/login",
    },

    {path: '/index', component: IndexPage},
    {path: '/query', component: QueryForm},
    // {path: '/profile', component: ProfilePage},
    {path: '/goodsManage', component: GoodsManagePage},
    {path: '/userManage', component: UserManagePage},

]

const router = createRouter({
    history: createWebHashHistory(),
    routes,
})

const app = createApp(LoginApp)

app.use(ElementPlus, {
    locale: zhCn,
})
app.mount('#app')
app.use(VueAxios, axios)
app.use(router)
app.use(HighchartsVue)

export function postBackend(url, data, suc, err) {
    const token = localStorage.getItem("Token")
    axios.post(url, qs.stringify(data), {
        headers: {
            "Token": token
        }
    }).then(suc, err)
}
